
** Shorter Code (to replicate tables and figures from paper) **

use "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"
* Make figure 1 *
sort decade
twoway connected mpolapp decade || lfit mpolapp decade, scheme(plotplain) ylabel(0(0.05)0.4) xlabel(1(1)8) legend(off)
twoway connected mdiploex decade || lfit mdiploex decade, scheme(plotplain) ylabel(0(5)25) xlabel(1(1)8) legend(off)
twoway connected mpriorambdum decade || lfit priorambdum decade, scheme(plotplain) ylabel(0(0.05)0.5) xlabel(1(1)8) legend(off)
twoway connected mpriorambdumpol mpriorambdumcar decade, scheme(plotplain) ylabel(0(0.05)0.6) xlabel(1(1)8) 
sort name

* Make table 1 *
summ diploex priorambdum age gender milexdum majpow usally demdummy
summ diploex priorambdum age gender milexdum majpow usally demdummy if polapp==0
summ diploex priorambdum age gender milexdum majpow usally demdummy if polapp==1

* Make table 2 *
* this is mean treated (political) UNMATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==1 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.
* this is mean control (career) UNMATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==0 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.
use "/Users/pmacdon2/Documents/macdonald_diplomats_MATCHED.dta"
* this is mean treated (political) MATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==1 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.
* this is mean control (career) MATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==0 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.

* Make table 3 *
use "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"
* Model 1*
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
* Model 2*
xtset region
xtlogit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, fe
* Model 3*
xtset ccode
xtlogit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, fe
* Model 4 *
use "/Users/pmacdon2/Documents/macdonald_diplomats_MATCHED.dta"
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)

* Make Table 4 *
use "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"
* Model 5 *
logit midtenure profpol usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
* Model 6 *
logit midtenure profbus usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
* Model 7 * 
logit midtenure profacad usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
* Model 8 *
logit midtenure presclose usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)

* Make Figure 2 *
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.presparty c.pressfrcdistance i.polapp#i.presparty i.polapp#c.pressfrcdistance, cluster(ccode)
margins, at(pressfrcdistance=(0 (.1) 1) polapp=(0 1)) atmeans
marginsplot, recastci(rarea) scheme(plotplain)


** Longer Code (to enter and label data from Excel file and generate all figures cited in tables, figures, text and footnotes in paper **
gen name=.
gen numdays=.
gen ccode=.
gen year=.
gen diploex=.
gen prioramb=.
gen polapp=.
gen milex=.
gen gender=.
gen age=.

la var name "Ambassador Number"
la var numdays "Number of Days Served"
la var ccode "Country Code of Posting"
la var year "Year of Posting Start Date"
la var diploex "Years of Diplomatic Experience prior to Posting"
la var prioramb "Number of Previous Postings"
la var polapp "Political Appointee Dummy Variable"
la var milex "Years of Military Experience prior to Posting"
la var gender "Female Dummy Variable"
la var age "Age at Posting Start Date"

gen usally=.
gen contig=.
gen distance=.
gen majpow=.
gen uscinc=.
gen hostcinc=.
gen peaceyears=.
gen polity=.
gen tradedep=.
gen igosame=.
gen gdppcrat=.
gen midtenure=.

la var usally "U.S. Ally Dummy Variable"
la var contig "Contiguity Dummy Variable"
la var distance "Capital City Distance"
la var majpow "Major Power Dummy Variable"
la var uscinc "U.S. capabilities"
la var hostcinc "Host capabilities"
la var peaceyears "Years since last MID"
la var polity "Polity 2 score"
la var tradedep "U.S. trade dependence on host"
la var igosame "Number shared IGOs with host"
la var gdppcrat "Ratio U.S. to host GDP per capita"
la var midtenure "Militarized dispute during ambassador tenure"

generate lncaprat=ln(uscinc/hostcinc)
generate lndistance=ln(distance)
generate lnpeaceyears=ln(1+peaceyears)
generate lngdppcrat=ln(gdpcaprat)

la var lncaprat "Log Capabilities Ratio"
la var lndistance "Log Capital City Distance"
la var lnpeaceyears "Log Years since last MID"
la var lngdppcrat "Log Ratio U.S./host GDP per capita"

generate milexdum=milex
replace milexdum=1 if milexdum>0
generate priorambdum=prioramb
replace priorambdum=1 if priorambdum>0

la var milexdum "Military Experience Dummy Variable"
la var priorambdum "Prior Ambassador Posting Dummy Variable"

save "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"

** Code for Section 3 "Diplomatic Experience and U.S. Ambassadors" **

use "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"

* Make Figure 1 * 

generate decade=.
replace decade=1 if year>1945 & year<1950
replace decade=2 if year>1949 & year<1960
replace decade=3 if year>1959 & year<1970
replace decade=4 if year>1969 & year<1980
replace decade=5 if year>1979 & year<1990
replace decade=6 if year>1989 & year<2000
replace decade=7 if year>1999 & year<2010
replace decade=8 if year>2009 & year<2020
la var decade "Decade of observation"

egen mdiploex=mean(diploex), by(decade)
egen mpriorambdum=mean(priorambdum), by(decade)
egen mpolapp=mean(polapp), by(decade)
egen mpriorambdumpol=mean(priorambdum) if polapp=1, by(decade)
egen mpriorambdumcar=mean(priorambdum) if polapp=0, by(decade)

la var mdiploex "Diplomatic experience, mean by decade"
la var mpriorambdum "Prior ambassadorial service, mean by decade"
la var mpolapp "Political appointee, mean by decade"
la var mpriorambdumpol "Prior ambassadorial service, for political, by decade"
la var mpriorambdumcar "Prior ambassadorial service, for career, by decade"

sort decade
twoway connected mpolapp decade || lfit mpolapp decade, scheme(plotplain) ylabel(0(0.05)0.4) xlabel(1(1)8) legend(off)
twoway connected mdiploex decade || lfit mdiploex decade, scheme(plotplain) ylabel(0(5)25) xlabel(1(1)8) legend(off)
twoway connected mpriorambdum decade || lfit priorambdum decade, scheme(plotplain) ylabel(0(0.05)0.5) xlabel(1(1)8) legend(off)
twoway connected mpriorambdumpol mpriorambdumcar decade, scheme(plotplain) ylabel(0(0.05)0.6) xlabel(1(1)8) 
sort name


* Summary statistics for section 3.1 *

generate cwdummy=year
replace cwdummy=0 if cwdummy>1989
replace cwdummy=1 if cwdummy>1944
la var cwdummy "Cold War dummy variable"

ttest polapp, by(cwdummy) unequal
ttest diploex, by(cwdummy) unequal
ttest diploex if polapp==1, by(cwdummy) unequal
ttest diploex if polapp==0, by(cwdummy) unequal
ttest priorambdum, by(cwdummy) unequal
summ polapp if cwdummy==1 & priorambdum==1

* Generate Table 1 and summary statistics for section 3.2 *

summ diploex priorambdum age gender milexdum majpow usally demdummy
summ diploex priorambdum age gender milexdum majpow usally demdummy if polapp==0
summ diploex priorambdum age gender milexdum majpow usally demdummy if polapp==1

summ diploex
ttest diploex, by(polapp) unequal
summ priorambdum
ttest priorambdum, by(polapp) unequal
summ age
ttest age, by(polapp) unequal
summ gender
ttest gender, by(polapp) unequal
summ gender if cwdummy==1
summ polapp if cwdummy==1 & gender==1
summ gender if cwdummy==0
summ polapp if cwdummy==0 & gender==1
summ milexdum
ttest milexdum, by(polapp) unequal
summ milexdum if cwdummy==0

summ majpow
ttest majpow, by(polapp) unequal
summ usally
ttest usally, by(polapp) unequal
genenerate demdummy=polity
replace demdummy=0 if demdummy<6
replace demdummy=1 if demdummy>5 & demdummy<11
la var demdummy "Host nation is a democracy, dummy variable"
summ demdummy
ttest demdummy, by(polapp) unequal

** Code for Section 4 "U.S. Ambassadors and Internaitonal Crises" **

summ midtenure
tab midtenure
ttest midtenure, by(polapp) unequal

** R code to create matched data using MatchIt *

* library(MatchIt)
* library(foreign)
* mydata <- read.dta("/Users/pmacdon2/Desktop/macdonald_diplomats_MATCH.dta")
* summary(mydata)
* m.out <- matchit(polapp ~ usally + contig + lndistance + majpow + lncaprat + polity + tradedep + igosame + lnpeaceyears + year + lngdppcrat, data=mydata, method="nearest", exact=c("usally", "contig", "majpow"))
* summary(m.out)
* m.data <-match.data(m.out)
* write.dta(m.data, "/Users/pmacdon2/Desktop/macdonald_diplomats_MATCHED.dta")
* z.out <- zelig(midtenure ~ polapp + usally + contig + lndistance + majpow + lncaprat + lnpeaceyears + numdays + polity + tradedep + igosame + lngdppcrat, data=match.data(m.out), model="logit")
* summary(z.out)
* x.out <-setx(z.out, polapp=0)
* x.out <-setx(z.out, polapp=0)
* x1.out <-setx(z.out, polapp=1)
* s.out <-sim(z.out, x = x.out, x1 = x1.out)
* summary(s.out)

* Code to generate table 2 for section 4.1 *

* this is mean treated (political) UNMATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==1 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.
* this is mean control (career) UNMATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==0 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.
use "/macdonald_diplomats_MATCHED.dta"
* this is mean treated (political) MATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==1 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.
* this is mean control (career) MATCHED
summ majpow lncaprat contig lndistance usally polity tradedep igosame lngdppcrat if polapp==0 & majpow!=. & lncaprat!=. & contig!=. & lndistance!=. & usally!=. & polity!=. & tradedep!=. & igosame!=. & lngdppcrat!=. & lnpeaceyears!=. & numdays!=.


** Code to generate Table 3 and for section 4.2 **

* install estout *
ssc install estout, replace

* Model 1*
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo re
margins, at(polapp=(0 1)) atmeans
summ lndistance lncaprat lnpeaceyears polity if e(sample)==1
margins, at(lndistance=(8.9506488 7.9649272)) atmeans
margins, at(lncaprat=(6.429036 3.220776)) atmeans
margins, at(lnpeaceyears=(4.174525 2.160001)) atmeans
margins, at(polity=(7.9866924 -6.8302096)) atmeans

generate region=ccode
replace region=1 if region>1 & region<99
replace region=2 if region>99 & region<200
replace region=3 if region>199 & region<400
replace region=4 if region>400 & region<600
replace region=5 if region>599 & region<700
replace region=6 if region>699 & region<900
replace region=7 if region>700 & region<1000
la var region "Region of host nation"

* Model 2*
xtset region
xtlogit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, fe
eststo fe_region
margins, at(polapp=(0 1)) atmeans

* Model 3*
xtset ccode
xtlogit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, fe
eststo fe_country
margins, at(polapp=(0 1)) atmeans
margins, at(lnpeaceyears=(4.16753 2.14928)) atmeans
margins, at(polity=(7.7659803 -7.0115137)) atmeans
margins, at(lncaprat=(6.410179 3.211249)) atmeans

generate bothambtype=.
la var bothambtype "Panel includes both career and political ambassadors"
xtlogit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat if bothambtype==1, fe

* For Table 3 *
esttab re fe_region fe_country using latex1.tex, se
drop _est_re _est_fe_region _est_fe_country

* Model 4 *
use "/Users/pmacdon2/Documents/macdonald_diplomats_MATCHED.dta"

logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo match
esttab match using latex2.tex, se
margins, at(polapp=(0 1)) atmeans
drop _est_match

* Political ambassador professional background hypothesis, to generate Table 4 and Section 5.1 *
use "/macdonald_diplomats_UNMATCHED.dta"
generate profpol=.
generate profbus=.
generate profacad=.
la var profpol "Political / military experience"
la var profbus "Business / law experience"
la var profacad "Academic / media experience"

* Model 5 *
logit midtenure profpol usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo profpol
margins, at(profpol=(0 1)) atmeans

* Model 6 *
logit midtenure profbus usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo profbus
margins, at(profbus=(0 1)) atmeans

* Model 7 * 
logit midtenure profacad usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo profacad

generate milcardum=milex
la var milcardum "Military career, dummy variable"
replace milcardum=0 if milcardum<5 & milcardum>0
replace milcardum=1 if milcardum>4 & milcardum<47
tab milcardum
sum milcardum if polapp==0
sum milcardum if polapp==1
la var milcardum "Military career, dummy variable"

* Political ambassador personal connections, to generate Table 4 **

generate presfriend=.
generate presneigh=.
la var presfriend "Attended president's alam mater"
la var presneigh "From preident's home state"
generate presclose=(presfriend+presneigh)
replace presclose=1 if presclose==2
la var presclose "Friend or neighbor of president"
logit midtenure presfriend usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
logit midtenure presneigh usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)

* Model 8 *
logit midtenure presclose usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo presclose

* For Table 4*
esttab profpol profbus profacad presclose using latex5.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

** Political ambassador and congressional oversight, for Appendix 6 and Figure 2 **

generate presparty=.
generate pressfrcdistance=.
la var presparty "President's party in control in Senate"
la var pressfrcdistance "Distnace between President and SFRC chair"

logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.presparty, cluster(ccode)
eststo presparty
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat c.pressfrcdistance, cluster(ccode)
eststo pressfrc
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.presparty c.pressfrcdistance, cluster(ccode)
eststo prespartysfrc

* To generate Figure 2 *
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.presparty c.pressfrcdistance i.polapp#i.presparty i.polapp#c.pressfrcdistance, cluster(ccode)
eststo prespartysfrcinter
margins, at(pressfrcdistance=(0 (.1) 1) polapp=(0 1)) atmeans
marginsplot, recastci(rarea) scheme(plotplain)

summ pressfrcdistance if e(sample)==1
margins, at(pressfrcdistance=(0.1877164 0.7764534) polapp==(0)) atmeans
margins, at(pressfrcdistance=(0.1877164 0.7764534) polapp==(1)) atmeans

esttab presparty pressfrc prespartysfrc prespartysfrcinter using latex6.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

* Alternative measures of attractiveness of post, for Appendix 2*

use "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"

generate tourists=.
generate lntourists=ln(tourists)
la var tourists "International tourism, number of arrivals"
la var lntourists "Log International tourism, number of arrivals"
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lntourists, cluster(ccode)
eststo re_tourists

generate touristspc=.
generate lntouristspc=ln(1+touristspc)
la var touristspc "Internaitonal tourism per capita"
la var lntouristspc "Log Internaitonal tourism per capita"
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lntouristspc, cluster(ccode)
eststo re_touristspc

generate airpass=.
generate lnairpass=ln(1+airpass)
la var airpass "Air transport, passengers carried"
la var lnairpass "Log Air transport, passangers carried"
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lnairpass, cluster(ccode)
eststo re_airpass

generate airpasspc=.
generate lnairpasspc=ln(1+airpasspc)
la var airpasspc "Air transport per capita"
la var lnairpasspc "Log Air transport"
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lnairpasspc, cluster(ccode)
eststo re_airpasspc

esttab re_tourists re_touristspc re_airpass re_airpasspc using latex1.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

drop _est_re_tourists _est_re_touristspc _est_re_airpass _est_re_airpasspc

* Declining bilateral relations hypothesis, for Appendix 3 *

generate d1sscore=.
generate d5sscore=.
generate d1agree=.
generate d5agree=.
la var d1sscore "Change in S-Score from 1-year prior"
la var d5sscore "Change in S-Score from 5-years prior"
la var d1agree "Change in Agree score from 1-year prior"
la var d5agree "Change in Agree score from 1-year prior"
summ d1sscore d5sscore d1agree d5agree
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat d1sscore, cluster(ccode)
eststo d1s
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat d5sscore, cluster(ccode)
eststo d5s
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat d1agree, cluster(ccode)
eststo d1a
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat d5agree, cluster(ccode)
eststo d5a
esttab d1s d5s d1a d5a using latex2.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
drop _est_d1s _est_d5s _est_d1a _est_d5a

* Previous conflict hypothesis, for Appendix 4 *

generate predmid=.
generate priormid=.
la var predmid "Ambassador's immediate predecessor experienced MID with US"
la var priormid "Ambassador's country has prior MID with US"
summ predmid priormid
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat predmid, cluster(ccode)
eststo predmid
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat priormid, cluster(ccode)
eststo priormid
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.predmid i.polapp#i.predmid, cluster(ccode)
eststo predmidinter
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.priormid i.polapp#i.priormid, cluster(ccode)
eststo priormidinter
esttab predmid priormid using latex3.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

* Country experience hypothesis, for Appendix 5 *

generate countryex=.
la var countryex "Host country experience, in years"
tab countryex
generate countryexdum=countryex
replace countryexdum=1 if countryexdum>0 & countryexdum<43
la var countryexdum "Host country experience, dummy"
tab countryexdum
summ countryexdum if polapp==0
summ countryexdum if polapp==1
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat countryexdum, cluster(ccode)
eststo cex1
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat i.countryexdum i.polapp#i.countryexdum, cluster(ccode)
eststo cex2

* Diplomatic experience hypothesis, for Appendix 5 *

generate diploexdum=diploex
replace diploexdum=1 if diploexdum>0 & diploexdum<45
la var diploexdum "Diplomatic experience, dummy"
tab diploexdum
summ diploexdum if polapp==0
summ diploexdum if polapp==1
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat diploexdum, cluster(ccode)
eststo dex1
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat diploex, cluster(ccode)
eststo dex2
logit midtenure i.polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat c.diploex c.diploex#i.polapp, cluster(ccode)
eststo dex3

esttab cex1 cex2 dex1 dex2 dex3 using latex4.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
drop _est_cex1 _est_cex2 _est_dex1 _est_dex2 _est_dex3


* New disputes only, for Appendix 7 *

generate midtenurenew=.
generate peaceyearsnew=.
generate lnpeaceyearsnew=(1+peaceyearsnew)
la var midtenurenew "Militarized Dispute (new only) during ambassador's tenure"
la var peaceyearsnew "Years since last MID (new only)"
la var lnpeaceyearsnew "Logged Years since last MID (new only)"

logit midtenurenew polapp usally contig lndistance majpow lncaprat lnpeaceyearsnew numdays polity tradedep igosame lngdppcrat, cluster(ccode)
eststo re_new

xtset region
xtlogit midtenurenew polapp usally contig lndistance majpow lncaprat lnpeaceyearsnew numdays polity tradedep igosame lngdppcrat, fe
eststo fe_region_new

xtset ccode
xtlogit midtenurenew polapp usally contig lndistance majpow lncaprat lnpeaceyearsnew numdays polity tradedep igosame lngdppcrat, fe
eststo fe_country_new

esttab re_new fe_region_new fe_country_new using latex7.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)



* Cold War vs Post Cold War, for Appendix 7 *
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat if cwdummy==1, cluster(ccode)
eststo re_cw
logit midtenure polapp usally contig lndistance majpow lncaprat lnpeaceyears numdays polity tradedep igosame lngdppcrat if cwdummy==0, cluster(ccode)
eststo re_postcw

esttab re_tourists re_cw re_postcw using latex8.tex, se star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
drop _est_re_tourists _est_re_cw _est_re_postcw

* By President charts, for Appendix 7 *

generate president=.
la var president "President who appointed ambassador"

egen mppolapp=mean(polapp), by(president)
egen mpdiploex=mean(diploex), by(president)
egen mppriorambdum=mean(priorambdum), by(president)
la var mppolapp "Average % Political Appointee, by President"
la var mpdiploex "Average Years Diplomatic Experience, by President"
la var mppriorambdum "Average % Prior Ambassadors, by President"

egen mpprofpol=mean(profpol), by(president)
egen mpprofbus=mean(profbus), by(president)
egen mpprofacad=mean(profacad), by(president)
egen mppresclose=mean(presclose), by(president)
egen mppressfrcdistance=mean(pressfrcdistance), by(president)
la var mpprofpol "Average % Political/Military Ambassadors, by President"
la var mpprofbus "Average Business/Law Ambassadors, by President"
la var mpprofacad "Average Academic/Media Ambassadors, by President"
la var mppresclose "Average `Friends and Neighbors' of President, by President"
la var mppressfrcdistance "Average President SFRC Ideological distance, by President"

sort president
twoway connected mppolapp president, scheme(plotplain)
twoway connected mpdiploex president, scheme(plotplain)
twoway connected mppriorambdum president, scheme(plotplain)
twoway connected mpprofpol mpprofbus mpprofacad president, scheme(plotplain)
twoway connected mppresclose president, scheme(plotplain)
twoway connected mppressfrcdistance president, scheme(plotplain)

sort name

save "/Users/pmacdon2/Documents/macdonald_diplomats_UNMATCHED.dta"





